package com.gking.centerSystem.config;


import com.baomidou.mybatisplus.generator.FastAutoGenerator;
import com.baomidou.mybatisplus.generator.engine.FreemarkerTemplateEngine;


/**
 * 用于生成数据库表对应的实体类、Mapper接口、Service接口、Controller等代码
 */
public class CodeGeneratorConfig {
    public static void main(String[] args) {

        FastAutoGenerator.create(
                        "jdbc:mysql://localhost:3306/gking_self_system?useUnicode=true&characterEncoding=utf-8&useSSL=false&allowPublicKeyRetrieval=true",
                        "root",
                        "gking")
                .globalConfig(builder -> builder
                                .author("GKing")
                                .outputDir("D://DeskTop")
                                .commentDate("yyyy-MM-dd")
//                        .disableOpenDir()
                )
                .packageConfig(builder -> builder
                        .parent("com.gking.centerSystem")
                        .entity("entity")
                        .mapper("mapper")
                        .service("service")
                        .serviceImpl("service.impl")
                        .xml("mapper.xml")
                )
                .strategyConfig(builder -> builder
                        .addInclude("access_policy")
                        .entityBuilder()
                        .enableLombok() // 启用 Lombok
                        .enableTableFieldAnnotation() // 启用字段注解
                        .controllerBuilder()
                        .enableRestStyle()
                )
                .templateEngine(new FreemarkerTemplateEngine()) // 使用 Freemarker 模板引擎
                .execute();
    }
}
